<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\CategoryQuery */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Categories';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="category-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('Create Category', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

//            'id',
            'code',
            'name',
            'parent_id',
//            'image_url:url',
            [
                'label' => '图片',
                'format' => [
                    'image',
                    [
                        'width'=>'84',
                        'height'=>'84'
                    ]
                ],
                'value' => function ($model) {
                    return $model->image_url;
                }
            ],
            [
//                'class' => 'yii\grid\RadioButtonColumn',
                'attribute'=>'is_show',
                'value'=>function($data){
                    return $data->is_show == 1 ? '显示' : '不显示';
                }
            ],
             'sort',
//             'mini_programs_id',
             'create_datetime',

            ['class' => 'yii\grid\ActionColumn'],
        ],
        'emptyText'=>'当前没有匹配的记录',
        'emptyTextOptions'=>['style'=>'color:red;font-weight:bold'],
        'layout'=>"{items}\n{pager}"
    ]); ?>
</div>
